perm filename TTYMES.SAI[AID,LSP]1 blob sn#376729 filedate 1978-09-29 generic text, type C, neo UTF8
COMMENT ⊗   VALID 00002 PAGES
C REC  PAGE   DESCRIPTION
C00001 00001
C00002 00002	begin "ttymes"
C00006 ENDMK
C⊗;
begin "ttymes"

string WHAT, S, OLD, HDR;
integer NUM, I, BEEP, OCT;
integer array BUF[1:2], WBUF[1:22];

define ↓ = "'15&'12";

call (cvsix("FINGER"), "setnam");
setbreak (1, '12, '15, "ki");
setbreak (2, '12, null, "fai");
print ("TTY #");	BUF[1] ← cvsix("TTY"&(S←inchwl));
print ("Beep?");	BEEP ← (inchwl lor '40 = "y");	OCT ← cvo(S);
HDR ← null;
if BEEP then
begin	print ("From?");
	if (S←inchwl) = "!" then
		HDR ← "!"
	else if S then
	begin	I ← (if S="∂" then OCT else cvo(S));
		if (I ← call (I, "ttyjob")) ≤ 0 then
			print ("No job on ", (if S="∂" then "receiv" else "send"), "ing tty!",'15&'12)
		else
		begin	call ((I lsh 18) + location(WBUF[1]), "who");
			HDR ← cvstr(WBUF[2])[2 for 3];
			while HDR = " " do HDR ← HDR[2 to ∞];
			if S = "∂" then
				HDR ← "∂;; Mail for " & HDR & " from " & scan(S,1,I)[2 to ∞] & "  " & '11
			else
			begin	HDR ← ";; Message from " & HDR & "   on TTY" & cvos(I←cvo(S));
				if '66 ≤ I ≤ '157 then
				begin	call ((-1 lsh 18) + location (('017400+I) lsh 18 + location (I)), "ttyset");
					if I < 0 then
					begin	print ("No responsible DD!",'15&'12);
						HDR ← null
					end
					else
						HDR ← HDR & " (at TV-" & cvos (I) & ")  "
				end
				else
					HDR ← HDR & "  "
			end
		end
	end
end;

S ← "Terminate message with null line."&'15&'12&
	"(include a space on ""null"" lines within text):"&'15&'12;
OLD ← null;

while true do
begin	print (S);	WHAT ← null;
	while S ← inchwl do WHAT ← WHAT & S & '15&'12;
	if equ (WHAT, "ditto"&'15&'12) then WHAT ← OLD;
	if length(OLD ← WHAT) = 0 then done;
	I ← call (0, "timer") % 3600;
	if HDR = "!" then
		WHAT ← (if length(WHAT)≤3 then "***** WARNING: AUTOMATIC LOGOUT IN FIVE MINUTES! *****" & ↓
			else ";;"&↓&";; Autologout"&↓&"Kjob"&↓&".")
	else if HDR = "∂" then WHAT ← HDR[2 to ∞] & scan(WHAT,2,I)
	else if HDR then WHAT ← HDR & cvs((I%60)*40+I+10000)[2 for 4] & '15&'12 & WHAT;
	NUM ← (length(WHAT ← WHAT&0) + 4) % 5;
	S ← "Next message (""ditto"" to repeat):"&'15&'12;

	begin	integer array TEXT[1:NUM];
		for I ← 1 step 1 until NUM do TEXT[I] ← cvasc(WHAT[I*5-4 for 5]);
		BUF[2] ← location (TEXT[1]);
		call (location (BUF[1]), "ttymes");
		if BEEP then call (OCT, "beep")
	end
end;

call ((-1 lsh 18) + location ((4 lsh 27) + '14), "ttyset");
quick_code	movei 0;
		'047000400015;
		jfcl;
		'047000000012
end

end "ttymes"